/*

  The contents of this file are subject to the Mozilla Public License Version
  1.1 (the "License"); you may not use this file except in compliance with
  the License. You may obtain a copy of the License at 
  
           http://www.mozilla.org/MPL/ 
  
  Software distributed under the License is distributed on an "AS IS" basis,
  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  for the specific language governing rights and limitations under the License. 
  
  The Original Code is AST'r Framework.
  
  The Initial Developer of the Original Code is
  ALCARAZ Marc (aka eKameleon) <vegas@ekameleon.net>.
  Portions created by the Initial Developer are Copyright (C) 2004-2007
  the Initial Developer. All Rights Reserved.
  
  Contributor(s) :
  
 */





import ewhiteboard.display.whiteboard.shapes.WhiteBoardShapeDisplay;

import pegas.draw.Canvas;

/**
 * This shape display contains a freehand display.
 * @author eKameleon
 */
class ewhiteboard.display.whiteboard.shapes.FreehandShapeDisplay extends WhiteBoardShapeDisplay 
{

	/**
	 * Creates a new FreehandShapeDisplay instance.
	 * @param sName:String the name of the display.
	 * @param target:MovieClip the DisplayObject instance control this target.
	 */
	public function FreehandShapeDisplay( sName:String , target:MovieClip )
	{
		super( sName , target ) ;
		container = MovieClip(view).createEmptyMovieClip( DEFAULT_CONTAINER_NAME , DEFAULT_CONTAINER_DEPTH ) ;
		_canvas = new Canvas( container ) ;
	}
	
	/**
	 * The default container movieclip name value.
	 */
	public static var DEFAULT_CONTAINER_NAME:String = "container" ;
	
	/**
	 * The default container movieclip depth value.
	 */
	public static var DEFAULT_CONTAINER_DEPTH:Number = 100 ;
	
	/**
	 * The freehand shape container reference.
	 */
	public var container:MovieClip ;
	
	/**
	 * Invoqued after the draw method and when the IBuilder is updated.
	 */
	public /*override*/ function viewChanged():Void 
	{
		
		x = shape.x ;
		y = shape.y ;
		
		_canvas.clear() ;
		_canvas.setData( shape.canvas ) ;
		_canvas.draw() ;
		
	}
	
	/**
	 * The Canvas reference of this shape.
	 */
	private var _canvas:Canvas ;

}